<%-- 
    Document   : list_report
    Created on : Apr 27, 2013, 11:33:57 PM
    Author     : fikri
--%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>.: Observation : list report :.</title>
        <script type="text/javascript">
            $(function() {
                $("#datepicker2").datepicker({
                    showOn: "button",
                    buttonImage: "${pageContext.request.contextPath}/images/icon/calendar.gif",
                    buttonImageOnly: true,
                    changeMonth: true,
                    dateFormat: 'dd/mm/yy',
                    changeYear: true
                });
            });
            function showDetails(i) {
                var cl = $('#icon' + i).attr('class');
                if (cl === '1') {
                    $('#icon' + i).attr('src', '${pageContext.request.contextPath}/images/icon/segi2.gif');
                    $('.detail' + i).show();
                    $('#icon' + i).attr('class', 2);
                } else {
                    $('#icon' + i).attr('src', '${pageContext.request.contextPath}/images/icon/segi1.gif');
                    $('.detail' + i).hide();
                    $('#icon' + i).attr('class', 1);
                }

            }
        </script>
    </head>
    <body>
        <s:useActionBean beanclass="exatrez.stripes.util.ListUtil" var="list"/>
        <s:form beanclass="exatrez.stripes.action.ObservationAction" name="form1">
            <div>

                <div id="page-title">
                    <span class="title">Searching</span>
                </div>   
                <p>
                    <label>Vessel</label>
                    <s:select name="observation.vessel.vesselId" style="width:150px" class="clearAll">
                        <s:option value="">Please Choose</s:option>
                        <s:options-collection collection="${list.vesselList}" label="vesselName" value="vesselId"/>
                    </s:select>
                </p>
                <p>
                    <label>Year Of Inspection</label>
                    <c:set var="count" value="5"/>
                    <c:set var="now" value="<%=new java.util.Date().getYear() + 1900 %>"/>
                    <s:select name="yearOfInspection" style="width:150px">
                        <s:option value="">Please Choose</s:option>
                        <s:option value="${now}">${now}</s:option>
                        <c:forEach var="i" begin="1" end="${count}">
                            <s:option value="${now - i}">${now - i}</s:option>
                        </c:forEach>
                    </s:select>
                </p>
                <p>
                    <label>&nbsp;</label>
                    <s:submit name="searchCloseReport" value="Search" class="btn"/>
                    <s:button name="clear" value="Clear" class="btn clear"/>
                </p>

            </div>

            <div>
                <table class="tablecloth">
                    <thead>
                        <tr>
                            <th>No.</th>
                            <th>Vessel Name</th>
                            <th>Date Of Inspection</th>                       
                            <th>Location</th>
                            <th>Total Obs.</th>
                            <th>Obs. Open <br/> H | M | L</th>
                            <th>Obs. closed <br/> H | M | L</th>
                            <th>Date Submit</th>
                            <th>Date Last <br/>Modified</th>
                            <th>Modified By</th>
                        </tr>
                    </thead>                    
                    <tbody>
                        <c:if test="${!empty actionBean.listOfObservation}">
                            <c:forEach items="${actionBean.listOfObservation}" var="item" varStatus="line">
                                <tr>
                                    <td>
                                        <img id="icon${line.count}" src="${pageContext.request.contextPath}/images/icon/segi1.gif" 
                                             onclick="showDetails('${line.count}')" class="1"/></td>
                                    <td><a href="observation?viewCloseReport&id=${item.observationId}">${item.vessel.vesselName}</a></td>
                                    <td><fmt:formatDate value="${item.dateOfInspection}" pattern="dd/MM/yyyy"/></td>                            
                                    <td>${item.location}</td>
                                    <td>${fn:length(item.taskList)}</td> 
                                    <td>
                                        <c:set var="highO" value="0"/>
                                        <c:set var="mediumO" value="0"/>
                                        <c:set var="lowO" value="0"/>
                                        <c:forEach items="${item.taskList}" var="i">
                                            <c:if test="${i.severity.severityCodeId eq '3' && i.statusRemarks.statusRemarkCodeId eq '2'}">
                                                <c:set var="highO" value="${highO + 1}"/>
                                            </c:if>
                                            <c:if test="${i.severity.severityCodeId eq '2' && i.statusRemarks.statusRemarkCodeId eq '2'}">
                                                <c:set var="mediumO" value="${mediumO + 1}"/>
                                            </c:if>
                                            <c:if test="${i.severity.severityCodeId eq '1' && i.statusRemarks.statusRemarkCodeId eq '2'}">
                                                <c:set var="lowO" value="${lowO + 1}"/>
                                            </c:if>
                                        </c:forEach>
                                        ${highO} | ${mediumO} | ${lowO}
                                    </td>
                                    <td>
                                        <c:set var="highC" value="0"/>
                                        <c:set var="mediumC" value="0"/>
                                        <c:set var="lowC" value="0"/>
                                        <c:forEach items="${item.taskList}" var="i">
                                            <c:if test="${i.severity.severityCodeId eq '3' && i.statusRemarks.statusRemarkCodeId eq '1'}">
                                                <c:set var="highC" value="${highC + 1}"/>
                                            </c:if>
                                            <c:if test="${i.severity.severityCodeId eq '2' && i.statusRemarks.statusRemarkCodeId eq '1'}">
                                                <c:set var="mediumC" value="${mediumC + 1}"/>
                                            </c:if>
                                            <c:if test="${i.severity.severityCodeId eq '1' && i.statusRemarks.statusRemarkCodeId eq '1'}">
                                                <c:set var="lowC" value="${lowC + 1}"/>
                                            </c:if>
                                        </c:forEach>
                                        ${highC} | ${mediumC} | ${lowC}
                                    </td>
                                    <td><fmt:formatDate value="${item.dateSubmit}" pattern="dd/MM/yyyy"/></td>
                                    <td><fmt:formatDate value="${item.infoAudit.updateDate}" pattern="dd/MM/yyyy"/></td>
                                    <td>${item.infoAudit.updateId.userId}</td>
                                </tr>
                                <tr class="detail${line.count}" style="display : none">
                                    <th>&nbsp;</th>
                                    <th>No.</th>
                                    <th>Title</th>
                                    <th>Severity</th>
                                    <th>Severity Days</th>
                                    <th>Added Days</th>
                                    <th>Summary</th>
                                    <th>Remark</th>
                                </tr>
                                <c:forEach items="${item.taskList}" var="detail" varStatus="line2">
                                    <tr class="detail${line.count}" style="display : none">
                                        <td>&nbsp;</td>
                                        <td>${line2.count}</td>
                                        <td>${detail.title}</td>
                                        <td>${detail.severity.severityName}</td>
                                        <td>${detail.severityDayCount}</td>
                                        <td>${detail.severityDayAdd}</td>
                                        <td>${detail.summary}</td>
                                        <td>${detail.statusRemarks.statusRemarkName}</td>
                                    </tr>
                                </c:forEach>
                            </c:forEach>
                        </c:if>
                        <c:if test="${empty actionBean.listOfObservation}">
                            <tr>
                                <td colspan="10">No Results.</td>
                            </tr>
                        </c:if>
                    </tbody>
                </table>
            </div>

        </s:form>
    </body>
</html>
